﻿Public Class ListArgHandler
    Implements IArgHandler

    Public Function GetValues(obj As RawObject, argument As ArgumentDefinition) As IEnumerable(Of String) Implements IArgHandler.GetValues
        Return argument.TypeData.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
    End Function

    Public Function ValidateArgument(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition, value As String) As String Implements IArgHandler.ValidateArgument
        Dim valueInList As Boolean = argument.TypeData.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries).Contains(value)
        If valueInList Then
            Return Nothing
        Else
            Return "Value must be in the list of options."
        End If
    End Function

    Public Function ValidateTypeData(typeData As String) As Boolean Implements IArgHandler.ValidateTypeData
        Return True
    End Function

    Public ReadOnly Property TypeDataFormat As String Implements IArgHandler.TypeDataFormat
        Get
            Return "item1 item 2 item3 item 4 ..."
        End Get
    End Property

    Public ReadOnly Property DefaultTypeData As String Implements IArgHandler.DefaultTypeData
        Get
            Return ""
        End Get
    End Property

    Public ReadOnly Property DefaultValue(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition) As String Implements IArgHandler.DefaultValue
        Get
            Dim ret As String = GetValues(obj, argument).FirstOrDefault
            If ret Is Nothing Then
                ret = ""
            End If
            Return ret
        End Get
    End Property

    Public Function Parse(argParts As System.Collections.Generic.IEnumerator(Of String), arg As ArgumentDefinition) As String Implements IArgHandler.Parse
        Return argParts.Current
    End Function

    Public Function GetNavList(library As RawLibrary, obj As RawObject, argument As ArgumentDefinition, value As String) As IEnumerable(Of NavPoint) Implements IArgHandler.GetNavList
        Return Nothing
    End Function
End Class
